package com.ly.common.running.config;

import com.ly.common.running.dao.MybatisDao;
import com.ly.common.running.dao.MybatisDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author luoyana
 * @version V1.0
 * @ClassName MybatisDaoAutoConfiguration
 * @description 获取数据库session
 * @update 2022/12/24
 */
@Configuration
@AutoConfigureAfter({MybatisAutoConfiguration.class})
public class MybatisDaoAutoConfiguration {
    /**
     * 配置MybatisDao，注入SqlSessionTemplate
     * @param sqlSessionTemplate
     * @return mybatisDao实例化对象
     */
    @Bean
    public MybatisDao mybatisDao(SqlSessionTemplate sqlSessionTemplate){
        MybatisDao mybatisDao = new MybatisDaoImpl(sqlSessionTemplate);
        return mybatisDao;
    }
}
